//
//  HMNetWorkTool.swift
//  sinaweibo
//
//  Created by WGP on 16/4/9.
//  Copyright © 2016年 WGP. All rights reserved.
//

import UIKit
import AFNetworking

//swift中的枚举不仅可以有成员,还可以有属性,还可以有方法

enum HMNetworkErrorEnum: Int
{
    case AccessTokenEmpty = -1
    case UidEmpty = -2
    case RepeatLoadStatus = -3
    
    var errorDescription: String
    {
        switch self
        {
        case AccessTokenEmpty: return "AccessToken没有值"
        case UidEmpty: return "uid没有值"
        case RepeatLoadStatus: return "有人在加载微博数据"
        }
    }
    
    func error() ->NSError
    {
        return NSError(domain: "cn.itheima.net", code: self.rawValue, userInfo: ["errorDescription":self.errorDescription])
    }
}

class HMNetWorkTool: AFHTTPSessionManager {
    
//    单例
    static let sharedInstance: HMNetWorkTool =
    {
        let tool = HMNetWorkTool()
        tool.responseSerializer.acceptableContentTypes?.insert("text/plain")
        return tool
    }()

}
